//
//  ZDUser.swift
//  1026SwiftSinaWeiBo
//
//  Created by Apple on 15/10/31.
//  Copyright © 2015年 itcast. All rights reserved.
//

import UIKit

class ZDUser: NSObject {
    
    //	字符串型的用户UID
    var idstr: String?
    
    //  友好显示名称
    var name: String?
    
    //  用户头像地址（中图），50×50像素
    var profile_image_url: String?
    

    //  是否是微博认证用户，即加V用户，true：是，false：否
    var verified: Bool = false      //Bool和Int等不能是可选类型， 否则KVC报错
    
    //  verified_type 没有认证:-1   认证用户:0  企业认证:2,3,5  达人:220
    var verified_type: Int = -1
    
    //  会员等级 1-6
    var mbrank: Int = 1
    
    
    
    var verifieImage: UIImage? {
    
            switch verified_type {
            case 0:
                return UIImage(named: "avatar_vip")
            case 2, 3, 5:
                return UIImage(named: "avatar_enterprise_vip")
            case 220:
                return UIImage(named: "avatar_grassroot")
            default:
                return nil
            }
    }
    
    var vipImage: UIImage? {
    
        if mbrank >= 1 && mbrank <= 6 {
        
            let imageName = "common_icon_membership_level\(mbrank)"
            
            return UIImage(named: imageName)
        }
        
        return nil
    }
    
    
    //MARK: - 字典转模型
    init(dict: [String: AnyObject]) {
        
        super.init()
        
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    
    
    override var description: String {
    
        let array = ["idstr", "name", "profile_image_url", "verified", "verified_type", "mbrank"]
        
        return "\n\t用户模型：\(dictionaryWithValuesForKeys(array))"
    }

}
